package com.mazaiting.reversesigned;

import android.Manifest;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.content.pm.SigningInfo;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
import android.widget.Toast;

import com.mazaiting.log.L;

public class MainActivity extends AppCompatActivity {
  
  // Used to load the 'native-lib' library on application startup.
  static {
    System.loadLibrary("native-lib");
  }
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Example of a call to a native method
    TextView tv = findViewById(R.id.sample_text);
    tv.setText(stringFromJNI());
    L.d("签名信息: " + getSignature());
  }
  
  public int getSignature() {
    PackageManager packageManager = this.getPackageManager();
    PackageInfo pi;
    int sign = 0;
    try {
      pi = packageManager.getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
      Signature[] signingInfo = pi.signatures;
      sign = signingInfo[0].hashCode();
    } catch (Exception ignored) {}
    return sign;
  }
  
  /**
   * A native method that is implemented by the 'native-lib' native library,
   * which is packaged with this application.
   */
  public native String stringFromJNI();
}
